package com.demo.flight.controller;

import com.demo.flight.config.Result;
import com.demo.flight.config.ResultCodeEnum;
import com.demo.flight.entity.Administrator;
import com.demo.flight.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @author ssy
 * @create 2022-03-24 13:24
 */


@CrossOrigin
@ResponseBody
@Controller
@RequestMapping("/login")
public class LoginController {
    
    @Autowired
    private LoginService loginService;
    
    @GetMapping("/qualify")
    public Result login(Administrator administrator) {
        if (administrator == null) {
            return Result.error(ResultCodeEnum.PARAM_ERROR);
        }
        if (loginService.login(administrator)) {
            return Result.success();
        }
        return Result.error(ResultCodeEnum.ACCOUNT_OR_PASSWORD_ERROR);
    }
    
}
